{% set bgp_evpn_grp = 'LEAF_EVPN' if 'spine' in inventory_hostname else 'SPINE_EVPN' %}
{% set bgp_ipv4_grp = 'LEAF' if 'spine' in inventory_hostname else 'SPINE' %}

service routing protocols model multi-agent
!
router bgp {{bgp_asn}}

   neighbor {{ bgp_evpn_grp }} peer-group   
   neighbor {{ bgp_evpn_grp }} description "Peer Group for All {{bgp_evpn_grp}} EVPN Nodes"
   neighbor {{ bgp_evpn_grp }} graceful-restart-helper
   neighbor {{ bgp_evpn_grp }} send-community extended
   neighbor {{ bgp_evpn_grp }} maximum-routes 100000 warning-only
   neighbor {{ bgp_evpn_grp }} ebgp-multihop 2
   neighbor {{ bgp_evpn_grp }} update-source Loopback0
{% for p in bgp_peers %}
   neighbor {{ lo_ip[p.peer].split('/')[0]}} peer-group {{ bgp_evpn_grp }}
   neighbor {{ lo_ip[p.peer].split('/')[0]}} remote-as {{p.remote_as}}
{% endfor %}
   !
   address-family evpn
      neighbor {{ bgp_evpn_grp }} activate
   !
   address-family ipv4
      no neighbor {{ bgp_evpn_grp }} activate
!

